It's not necessarily more expensive than home cooking. A value menu cheeseburger at McDonald's is $1[1]. First result on google[2] says ground beef, 100% beef, per lb. is $3.75. The McDonald's cheeseburger's patty has a weight of 1.6oz or .1lbs, which of the aforementioned ground beef would cost $0.375. Tomato is estimated at $0.08 cents per slice, buns at $0.41 per bun, and lettuce at $0.02 for a leaf[4]. The slice of cheese is estimated at $0.29[5].
.375 + .08 + .41 + .02 + .29 = 1.175. So the homemade burger costs more not even accounting for the opportunity cost of the time to make it, the fact that you're probably not going to use all those ingredients and eventually throw some of them out, gas/electric for the stove, and possible butter/vegetable oil.
Not that it isn't worth it to make homemade burgers - they're definitely better than McDonald's, especially if you get local grass fed beef, but I like the unique taste of fast food restaurants and the economies of scale work in their favor to make things cheap, sometimes cheaper than cooking it yourself.
And on health, I don't see how the McDonald's burger is any worse for you than a homecooked one. McDonald's one probably has less grease. Maybe beef quality, but I'm not sure quality of beef has a direct impact on healthiness.
1: https://www.fastfoodmenuprices.com/mcdonalds-prices/
2: https://www.bls.gov/regions/mid-atlantic/data/AverageRetailF...
3: https://en.wikipedia.org/wiki/List_of_McDonald%27s_products
4: https://www.aol.com/2011/03/01/savings-experiment-the-great-...
5: https://www.marketwatch.com/story/heres-exactly-how-much-you...
More realistic would be to compare the food value derived from a $1 McDonalds hamburger with what $1 can buy at a discount/bulk grocery store in dried beans, sweet potatoes, onions, and other high bang-for-buck items.