Many parts of Github would not exist without intellectual property laws. If you post code, it's not just a free for all, you still have licenses and own your contributions if not specified otherwise. Especially company stuff would be much, much less open.
That's not to say that every facet of IP law is good, or even a judgement on it. Just pointing out that only parts of Github work like you describe.