An each-way bet is two bets of the same size: one on the win, one on the place. This works out both halves at your place terms, so you can see the return when it wins and the return when it only places.
An each-way bet is really two bets of the same stake: a win bet and a place bet. That is why $20 each-way costs $40 — you are staking $20 on each half. The win half pays the full price if your selection wins. The place half pays a fraction of the price if it finishes in the paying places.
The place fraction is set by the market, most often 1/5 or 1/4 of the win odds. So an 8.00 selection at 1/5 place terms pays 2.40 on the place half. If it wins you collect on both halves; if it only places you collect the place half alone, which on bigger prices can still return more than your whole outlay.
Each-way shines on longer-priced selections in races with several places, where the place return covers the stake and the win becomes a bonus. It is poor value on short-priced favourites, where a fifth of small odds barely covers the doubled stake.