Is it dangerous from the SEO perspective to do 301 redirect to my
homepage from all kind of subdomains that I don't use/not exist?
If they don't exist, the more appropriate status code for your server to return for these subdomains is a 410 Gone, which:
Indicates that the resource requested is no longer available and will
not be available again. This should be used when a resource has
been intentionally removed and the resource should be purged. Upon
receiving a 410 status code, the client should not request the
resource again in the future. Clients such as search engines should
remove the resource from their indices.
And does it help with the Google's index?
If you 301 redirect the subdomains to the URL of your home page, you'll just be telling search engines that they permanently moved to that URL and to continue indexing it, so it won't really help anything.
You're best option is to use a 410 to cut-down on user confusion and bounce rate, which Google may use a metric signal, and also to eventually reduce the load on your server due to the crawling of these non-existent links.