What's the difference between 72ppi and 300ppi?
I created two documents with same pixel dimensions (1280x768).
Document 1: 72ppi
Document 2: 300ppi
When I saved both in
.png, they have the same size on the hard disk. Why do I need PPI? Why can't I just use pixels?
Because in print, you need other dimensions as well as the information of the density to be able to judge if the result will print ok. Yes, as long as you stick to web you can mostly ignore it. But in print it makes all the difference.
Answering the specific points in the question:
...two documents with same pixel dimensions (1280x768)...
When I saved both in .png, they have the same size on the hard disk
Those aren't normal low and high res variants - what you have there, is two images that are identical, except that the low PPI thinks it's going to spread those 1280x768 pixels thinly across a large area, while the high PPI one thinks it's going to concentrate those 1280x768 pixels in a high quality print on a small area. But the important stuff - the data - is the same.
I'm guessing what happened here is, you changed the resolution in [something like] Photoshop leaving [something like] the 'Resample Image' box unchecked.
This means your image didn't actually change - it just changed how many inches of paper it thinks it can stretch those pixels over.
If you go back to the 300ppi original and scale it down again with "resample image" (or equivalent) checked, it should give you the more lightweight low-res file you expected.
If you'd had the 'Resample image' box or equivalent checked when you changed the resolution down from 300 to 72 to make the low-res image, it would have kept the size in inches or centimeters the same, and simplified the image so that each inch had only 72 pixels instead of 300. For example, If you had a business card design, 3.5 inches by 2 inches, 300 PPI, and you did this, it would still be a 3.5 inch by 2 inch business card, but it would have fewer pixels. It would be a smaller file and would print lower quality, on paper of the same size.
If the 'Resample image' box was unchecked, it would keep the 1250 by 600 pixels, and just calculate how many inches this could cover at 72 pixels per inch. It would be exactly the same image, just thinking it could print bigger because it thinks you're less fussy about print quality, so it thinks it can stretch its pixels further.