Which actually brings me to another point; the brain does not run exclusively on carbs (glucose) - it absolutely has the ability to (and does) functions well on ketones. This is why ketogenic diets can work for many people.
But yes, there's lots of bio-chemical mechanisms that get kicked off when you're fasting for an extended period, so it could be something else that's unique to the people who experience the euphoria.
I am not sure if you've come across this concept, but "Metabolic Flexibility" seems to be trying to explain some of the "after burner" affects of switching around my dieting habits. Where I am no longer exercising strict caloric restrictions, or fasting on a regimen, but I am still observing some of the benefits of when I switched over. (Less bloating, more energetic even after a large meal, less voracious appetite on normal days).
Its a state where your body and mind need to be the sharpest in order to catch food. Or else due to lack of fuel you will enter actual starvation (no fat reserves).
When you have reduced calories intake ~~500kcal a day you are signaling to your body that you can find/catch food but there is not a lot of it. Your metabolism will slow down in order to adjust to reduce calories. You loose muscle mass much faster than when not eating at all.
I have done multiple >3 days fasts and I havent experienced this sharpness feeling though. It seems some people do and some don't.
Also worth mentioning keto is natural diet of Eskimo people, they survived generations eating seal's meat and fat. So keto is not some crazy nutjob diet invention of 21st cent.
Your brain runs on carbs. The easiest source of carbs is carb rich food. This is why hangry people seem to want nothing but cookies & candy IMO. But your body can only hold a limited amount of free carbs at any time. Meanwhile, your liver can convert fat to carbs to feed your brain, and your body can hold a virtually unlimited amount of fat. This pathway is more difficult, so you have to train your body to use it.
So I don't think it makes you smarter or more energetic. But it does make you more stable & help avoid the crash.