It sounds like your motherboard is starting to fail, the cpu is the likely cause, which would explain it getting hot and failing to boot sometimes. Also you should clean the inside of your Macbook, dust build up can cause this heating issue too, and getting to hot will hurt the cpu, which will cause it to die sooner. If its clean then you can try downloading an app like TG Pro, it monitors the temp and the fan, and it allows you to take control of your fan, so when its hot you can run it at 4400rpm for a bit to cool down. Which is good because MacOS will rarely let the fan go that fast, but keeping the rpms low just slows down the cooling.