I would like to do version control on some important directories on my server such as /etc/apache. All the files and subdirectories in that directory are owned by root:root. Would it be considered a security risk to create a public/private key pair for my root user, add that key to a Github repo, and then store that apache directory on Github? If it is a security risk, what's the "best practice" method of storing system directories (as opposed to personal directories) on Github?
It's not a security risk per se - public keys are public.
However you may still want to keep your config files at least somewhat private rather then expose them to the whole world on github. What if you have a misconfiguration in the config that has some security implications? You don't necessarily show it to everyone.
Have a look at GitHub Private repositories (you'll need a subscription), or look at GitLab (private repos are free), or host your GIT repo on some server that you control.
If the public key is accessible to anyone you don't trust, it is a security risk unless a key of sufficient length was generated. It does take a LOT of computing power and time to factor out all of the prime numbers used in creating an RSA key pair, but with enough time and effort the key can be broken. However, by A LOT.. I mean A LOT of time and effort. Like, hundreds years of computing. Usually the only people with these kind of resources available are governments and even then they can have difficulty breaking the encryption.
HOWEVER! When you generate an ssh RSA key pair, you can make it more difficult, so difficult it becomes essentially impossible, for anyone to reverse engineer your private key by increasing the length of the keys generated. For each additional bit, you increase the amount of work a computer has to do to crack your code by about a factor of 2. The default length for RSA keys in ssh is 2048. The following is an example of creating a key with a size of 4096.
ssh-keygen -t rsa -b 4096
This key should be significantly harder to crack and can be increased in size from there even. Git hub recommends that you use a bit length of 4096 when creating RSA keys.