What Google did is an interesting example but at least jbri's comment referred to breaking functionality if you changed it at all so it needed to be copied.
Oracle did make the point that Google didn't copy enough for compatibility and Write Once Run Anywhere effectively forking their entire ecosystem/platform without a license. It has killed Java on mobile (although maybe it would have happened anyway and maybe it is a good thing with Oracle running the show). I think that if the participants in the case hadn't been the most hated and loved companies in tech many people might have had a different view of the case.
There are a number of other reasons for copying an API than compatibility.
1) Its an efficient (lazy?) way to get to a well designed API without you having to do multiple rounds of iterative design as users hammer on it over several years.
2) Existing documentation can be used. [Documentation, tutorials StackOverflow answers].
3) Users are already familiar with it.
It seems to me that Google did a pretty vicious embrace, extend, extinguish on mobile Java and they may still be the better custodians of the platform but I'm not sure the behaviour is actually acceptable in general. They took maximum benefit from Sun's efforts to create a platform and a community and give the absolute minimum back. Just imagine if it was Microsoft (or even Apple) in the Google roll and old Sun (rather than Oracle) in the Oracle roll - would you still feel the same about the case?
Now does this mean I want to be locked into a provider unable to find an alternative implementer of a required library - absolutely not. But that is a factor to consider when adopting a platform/library as a cost to be weighed against the benefits. I always like an exit option or accept significant risk if I don't have one. Obviously API developers could offer permissive licenses to the API even if the library itself is closed source as a way to reassure customers and gain business. I'm not sure law is required OR desirable in this area.