High-fidelity entanglement and detection of alkaline-earth Rydberg atoms