- What are these designed to accomplish?
- If I'm trying to implement a wallet that doesn't need bitcoind to be installed to work, which one should I use?
- What existing libraries implement the low-level details of these protocols?
What are these designed to accomplish?
The peer-to-peer network is designed primarily to communicate blocks and transactions between full nodes. It has also been extended over time to allow SPV clients to request filtered data, as well as to communicate alerts for full nodes and to distribute address information for full nodes that accept incoming connections.
The RPC interface is designed to allow users to operate Bitcoin Core, either manually or programatically. About half of its calls are related to Bitcoin Core's optional built-in wallet, with the other half being split among control functions, data retrieval functions, and utility functions. A new HTTP REST interface also provides some data retrieval functions.
 Only Bitcoin Core uses this feature currently, although it's possible for the network to handle alerts propagated by other software.
If I'm trying to implement a wallet that doesn't need bitcoind to be installed to work, which one should I use?
All wallets need Bitcoin Core to be installed somewhere, but it's possible to write a wallet that communicates with other people's Bitcoin Core instances using the peer-to-peer protocol.
What existing libraries implement the low-level details of these protocols?
For the RPC-JSON interface, some libraries such as ocaml Bitcoin provide an extensive wrapper around the native RPC-JSON interface, adding typing and other features. However, all that is required to interface with Bitcoin Core's RPC-JSON interface is a library that handles HTTP sockets and a library that processes JSON. (But, if you implement this yourself, please read the proper money handling wiki page
The Peer to Peer protocol (using
getdata, ... etc. messages) is used by all clients communicating on the network. This protocol is how data is spread through the network. This is done directly over TCP/IP. Messages have their own format (not JSON) and allow the spread of transactions and blocks through the network. Read more at: https://bitcoin.org/en/developer-reference#protocol-versions.
After a Bitcoin Core full node has received the block and transaction data via this P2P protocol, then a user can use the RPC interface to query the node about the data it has received. The JSON-RPC interface used is specific to Bitcoin Core, although other clients may introduce similar interfaces for ease of use. Nodes do not typically communicate with each other using the RPC interface at all, the RPC calls are more like tools that Bitcoin Core provides for developers to give them access to the blockchain data.
The P2P protocol is how Bitcoin nodes talk to eachother. All Bitcoin software implements (part of) this protocol.
The RPC protocol is how you communicate with Bitcoin Core's bitcoind. Other Bitcoin software may have other ways of operating it.